package controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/*
* 控制器的类
* */
@Controller
public class FirstController {
    //localhost：8080/springMVC02/hello/....

    @RequestMapping("/hello")
    public String toHello(Model model){
        //封装数据
        model.addAttribute("mmm","扎姆斯，这是一个注解");
        //跳转页面
        return "user/hello";
    }

    @RequestMapping("/regist")
    public String toAddUser(Model model){
        return "user/regist";
    }

    @RequestMapping("/addUser")
    public String addUser(HttpServletRequest request,Model model){

        String username=request.getParameter("username");
        String password=request.getParameter("password");
        System.out.println("到了控制器层");
        System.out.println("用户名："+username+",密码："+password);

        model.addAttribute("key","测试代码");
        /*if(*//*如果业务逻辑层返回数字1*//*){
            return "注册成功的页面";
        }else{
            return "注册失败页面";
        }*/
        return "user/Vectory";

    }
}
























